/* 
 * File:   ShortMsgItem.cpp
 * Author: bd
 * 
 * Created on March 28, 2011, 8:59 PM
 */

#include "ShortMsgItem.hpp"

ShortMsgItem::ShortMsgItem() :
id(0), groupId(0), xid(0),
status(INITIAL), retry(0)
{

}

std::ostream & operator<<(std::ostream& os, const ShortMsgItem& smi)
{
    using namespace boost::posix_time;
    os << "(" << smi.id << "," <<
            smi.groupId << "," <<
            smi.xid << "," <<
            "'" << smi.toAddr << "'" << "," <<
            "'" << smi.fromAddr << "'" << ", " <<
            "'" << to_simple_string(smi.insertDate) << "'" << "," <<
            smi.status << "," <<
            "'" << smi.handler << "'" << "," <<
            "'" << to_simple_string(smi.lastUpdate) << "'" << "," <<
            smi.retry << ")";
    return os;
}

std::ostream& serialize(std::ostream& os, const ShortMsgItem& smi)
{
    os << smi;
    return os;
}

std::ostream& serializeXml(std::ostream& os, const ShortMsgItem& smi)
{
    using namespace boost::posix_time;
    os << "<shortmsg_item>" <<
            "<id>" << smi.id << "</id>" <<
            "<group_id>" << smi.groupId << "</group_id>" <<
            "<x_id>" << smi.xid << "</x_id>" <<
            "<to_addr>" << smi.toAddr << "</to_addr>" <<
            "<from_addr>" << smi.fromAddr << "</from_addr>" <<
            "<insert_date>" << "'" << to_simple_string(smi.insertDate) << "'" << "</insert_date>" <<
            "<status>" << smi.status << "</status>" <<
            "<handler>" << smi.handler << "</handler>" <<
            "<last_update>" << "'" << to_simple_string(smi.lastUpdate) << "'" << "</last_update>" <<
            "<retry>" << smi.retry << "</retry>" <<
            "</shortmsg_item>";

    return os;
}